package it.polito.connectedcar.tcc.zone;

import it.polito.connectedcar.util.TestZones;

import java.util.ArrayList;
import java.util.List;

/**
 * This class is in charge of managing multiple zones for a TCC. It is able to
 * load all of them from some source storage and it maintains them in memory.
 * 
 * @author Nicola Aresta
 * 
 */
public class TCCZonesManager {

	private List<TCCZone> zones;
	private static TCCZonesManager zonesManager;

	public static synchronized TCCZonesManager getInstance() {
		if (zonesManager == null)
			zonesManager = new TCCZonesManager();
		return zonesManager;
	}

	private TCCZonesManager() {

		setup();
	}

	/**
	 * initialize the ZonesManager with the managed zones. For each Zone , setup
	 * the next-hop Tokens and the list of vehicles
	 */
	private void setup() {
		zones = new ArrayList<TCCZone>();

		TestZones ts = TestZones.getInstance();
		zones.addAll(ts.getTestTCCZones());
	}

	public List<TCCZone> getZones() {
		return zones;
	}

	public void setZones(List<TCCZone> zones) {
		this.zones = zones;
	}
}
